<template>
    <el-main>
        <el-main class="ep-body">
            <epl-top-bar showCompany  companyType="COMPANY_AAB000_EXACT" cpTagType="COMPANY_SIMPLE_GROUP">
            </epl-top-bar>
            <epl-userMessage idCount="8" dataType="person">
            </epl-userMessage>
            <el-card class="ep-card">
                <el-form :model="form" ref="form" :rules="rules">
                    <ep-title>请输入文件导入信息</ep-title>
                    <el-row :gutter="10">
                        <ep-input colspan="8" label="基金统筹渠道" name="jjtcqd" rules="this.$rules.test_noBlank"  placeholder="请输入基金统筹渠道" :property="form.jjtcqd" p="R"
                                  :datas="{formData:form}"></ep-input>
                        <ep-input colspan="8" label="证件号码" name="aac147"  rules="this.$rules.test_noBlank" :property="form.aac147" p="R" placeholder="请输入证件号码"
                                  :datas="{formData:form}"></ep-input>
                        <ep-select colspan="8"  label="证件类型" name="aac058" placeholder="请选择证件类型" :property="form.aac058" codetype="AAC058"
                                   p="R"  rules="this.$rules.test_noBlank" :datas="{formData:form}" ></ep-select>
                    </el-row>
                    <el-row :gutter="10">
                        <ep-input colspan="8" label="姓名" name="aac003" rules="this.$rules.test_noBlank"  placeholder="请输入姓名" :property="form.aac003" p="R"
                                  :datas="{formData:form}"></ep-input>
                        <ep-select colspan="8"  label="性别" name="aac004" placeholder="请选择性别" :property="form.aac004" codetype="AAC004"
                                   p="R"  rules="this.$rules.test_noBlank" :datas="{formData:form}" ></ep-select>
                        <ep-input colspan="8" label="民族" name="aac005"  rules="this.$rules.test_noBlank" :property="form.aac005" p="R" placeholder="请输入民族"
                                  :datas="{formData:form}"></ep-input>
                    </el-row>
                    <el-row :gutter="10">
                        <ep-date colspan="8" label="出生日期" name="aac006" :property="form.aac006" placeholder="请选择出生日期"
                                 p="R" :datas="{formData: form }" type="date" rules="this.$rules.test_noBlank"></ep-date>
                        <ep-select colspan="8"  label="户口性质" name="aac009" placeholder="请选择户口性质" :property="form.aac009" codetype="AAC009"
                                   p="R"  rules="this.$rules.test_noBlank" :datas="{formData:form}" ></ep-select>
                        <ep-input colspan="8" label="户口所在地" name="aac010"  rules="this.$rules.test_noBlank" :property="form.aac010" p="R" placeholder="请输入户口所在地"
                                  :datas="{formData:form}"></ep-input>
                    </el-row>
                    <el-row :gutter="10">
                        <ep-select colspan="8"  label="精减人员类别" name="aac084" placeholder="请选择精简人员类别" :property="form.aac084" codetype="AAC084"
                                   p="R"  rules="this.$rules.test_noBlank" :datas="{formData:form}" ></ep-select>
                        <ep-input colspan="8" label="发放机构地" name="eae443"  rules="this.$rules.test_noBlank" :property="form.eae443" p="R" placeholder="请输入发放机构地"
                                  :datas="{formData:form}"></ep-input>
                        <ep-select colspan="8"  label="发放途径" name="bic121" placeholder="请选择精发放途径" :property="form.bic121" codetype="BIC121"
                                   p="R"  rules="this.$rules.test_noBlank" :datas="{formData:form}" ></ep-select>
                    </el-row>
                    <el-row :gutter="10">
                        <ep-input colspan="8" label="邮政编码" name="aae007"  rules="this.$rules.test_noBlank" :property="form.aae007" p="R" placeholder="请输入邮政编码"
                                  :datas="{formData:form}"></ep-input>
                        <ep-input colspan="8" label="联系人姓名" name="aae004"  rules="this.$rules.test_noBlank" :property="form.aae004" p="R" placeholder="请输入联系人姓名"
                                  :datas="{formData:form}"></ep-input>
                        <ep-input colspan="8" label="联系电话" name="aae005"  rules="this.$rules.test_noBlank" :property="form.aae005" p="R" placeholder="请输入联系电话"
                                  :datas="{formData:form}"></ep-input>
                    </el-row>
                    <el-row :gutter="10">
                        <ep-select colspan="7" label="联系地址" name="bae011" :property="form.bae011" placeholder="请输入联系地址所在省"
                                   p="R" :datas="{formData:form}"  codetype="BAE007"  isPageFilter></ep-select>
                        <ep-select colspan="4" label=""  name="bae012" :property="form.bae012" placeholder="请输入联系地址所在市"
                                   p="R" :datas="{formData:form}" codetype="BAE008"  isPageFilter formData="formData" isChange  label-width="0"
                                   SelectFilterData=" (':bae011' is null or substr(aaa102,0,2)=substr(':bae011',0,2)) "></ep-select>
                        <ep-select colspan="4" label=""  name="bae013" :property="form.bae013" placeholder="请输入联系地址所在区县"
                                   p="R" :datas="{formData:form}" codetype="BAE009"  isPageFilter label-width="0"
                                   SelectFilterData=" (':bae012' is null or substr(aaa102,0,4)=substr(':bae012',0,4))"></ep-select>
                        <ep-input  colspan="9" label="" name="aae006" :property="form.aae006" placeholder="请输入详细联系地址"
                                   p="R" :datas="{formData: form }" label-width="0"></ep-input >
                    </el-row>
                    <el-row :gutter="10">
                        <ep-select colspan="8"  label="待遇类别" name="eae003" placeholder="请选择待遇类别" :property="form.eae003" codetype="EAE003"
                                   p="R"  rules="this.$rules.test_noBlank" :datas="{formData:form}" ></ep-select>
                        <ep-date colspan="8" label="开始年月" name="aae041" :property="form.aae041" placeholder="请选择开始年月"
                                 p="R" :datas="{formData: form }" format="yyyyMM" type="date" rules="this.$rules.test_noBlank"></ep-date>
                        <ep-date colspan="8" label="终止年月" name="aae042" :property="form.aae042" placeholder="请选择终止年月"
                                 p="R" :datas="{formData: form }" format="yyyyMM" type="date" rules="this.$rules.test_noBlank"></ep-date>
                    </el-row>
                    <el-row :gutter="10">
                        <ep-input colspan="8" label="待遇金额" name="aae019"  rules="this.$rules.test_noBlank" :property="form.aae019" p="R" placeholder="请输入待遇金额"
                                  :datas="{formData:form}"></ep-input>
                        <ep-input colspan="8" label="发放比例" name="ffbl"  rules="this.$rules.test_noBlank" :property="form.ffbl" p="R" placeholder="请输入发放比例"
                                  :datas="{formData:form}"></ep-input>
                    </el-row>
                    <el-row>
                        <ep-textarea :rows="3" label="备注" name="aae013" :property="form.aae013" placeholder="请输入备注信息"
                                     p="E" :datas="{formData: form}"></ep-textarea>
                    </el-row>

                    <el-row type="flex" justify="center">
                        <ep-saveButton id="doSave" type="primary" top="20" bottom="20" ref="save" @formValidate="formValidate"
                                       :validate="['form']"
                                       :datas="{formData: form,panel:panel}"></ep-saveButton>
                    </el-row>
                </el-form>
                <el-tabs v-model="activeName2" type="card">
                    <el-tab-pane label="人员导入校验成功信息" name="1">
                        <ep-table :data="tableData1" edited="true" :pager="20">
                            <ep-table-column editor="text" name="jjtcqd" header="基金统筹渠道"></ep-table-column>
                            <ep-table-column editor="text" name="aac147" header="证件号码"></ep-table-column>
                            <ep-table-column editor="text" name="aac058" header="证件类型"></ep-table-column>
                            <ep-table-column editor="text" name="aac003" header="姓名"></ep-table-column>
                            <ep-table-column editor="text" name="aac004" header="性别"></ep-table-column>
                            <ep-table-column editor="text" name="aac005" header="民族"></ep-table-column>
                            <ep-table-column editor="text" name="aac006" header="出生日期"></ep-table-column>
                            <ep-table-column editor="text" name="aac009" header="户口性质"></ep-table-column>
                            <ep-table-column editor="text" name="aac010" header="户口所在地"></ep-table-column>
                            <ep-table-column editor="text" name="aac084" header="精减人员类别"></ep-table-column>
                            <ep-table-column editor="text" name="eae443" header="发放机构地"></ep-table-column>
                            <ep-table-column editor="text" name="bic121" header="发放途径"></ep-table-column>
                            <ep-table-column editor="text" name="aae007" header="邮政编码"></ep-table-column>
                            <ep-table-column editor="text" name="aae004" header="联系人姓名"></ep-table-column>
                            <ep-table-column editor="text" name="aae005" header="联系电话"></ep-table-column>
                            <ep-table-column editor="text" name="address" header="联系地址"></ep-table-column>
                            <ep-table-column editor="text" name="eae003" header="待遇类别"></ep-table-column>
                            <ep-table-column editor="text" name="aae041" header="开始年月"></ep-table-column>
                            <ep-table-column editor="text" name="aae042" header="终止年月"></ep-table-column>
                            <ep-table-column editor="text" name="aae019" header="待遇金额"></ep-table-column>
                            <ep-table-column editor="text" name="ffbl" header="发放比例"></ep-table-column>
                            <ep-table-column editor="text" name="aae013" header="备注"></ep-table-column>
                        </ep-table>
                    </el-tab-pane>
                    <el-tab-pane label="人员导入校验失败信息" name="2">
                        <ep-table :data="tableData2" :pager="20">
                            <ep-table-column editor="text" name="failinfo" header="失败信息"></ep-table-column>
                            <ep-table-column editor="text" name="jjtcqd" header="基金统筹渠道"></ep-table-column>
                            <ep-table-column editor="text" name="aac147" header="证件号码"></ep-table-column>
                            <ep-table-column editor="text" name="aac058" header="证件类型"></ep-table-column>
                            <ep-table-column editor="text" name="aac003" header="姓名"></ep-table-column>
                            <ep-table-column editor="text" name="aac004" header="性别"></ep-table-column>
                            <ep-table-column editor="text" name="aac005" header="民族"></ep-table-column>
                            <ep-table-column editor="text" name="aac006" header="出生日期"></ep-table-column>
                            <ep-table-column editor="text" name="aac009" header="户口性质"></ep-table-column>
                            <ep-table-column editor="text" name="aac010" header="户口所在地"></ep-table-column>
                            <ep-table-column editor="text" name="aac084" header="精减人员类别"></ep-table-column>
                            <ep-table-column editor="text" name="eae443" header="发放机构地"></ep-table-column>
                            <ep-table-column editor="text" name="bic121" header="发放途径"></ep-table-column>
                            <ep-table-column editor="text" name="aae007" header="邮政编码"></ep-table-column>
                            <ep-table-column editor="text" name="aae004" header="联系人姓名"></ep-table-column>
                            <ep-table-column editor="text" name="aae005" header="联系电话"></ep-table-column>
                            <ep-table-column editor="text" name="address" header="联系地址"></ep-table-column>
                            <ep-table-column editor="text" name="eae003" header="待遇类别"></ep-table-column>
                            <ep-table-column editor="text" name="aae041" header="开始年月"></ep-table-column>
                            <ep-table-column editor="text" name="aae042" header="终止年月"></ep-table-column>
                            <ep-table-column editor="text" name="aae019" header="待遇金额"></ep-table-column>
                            <ep-table-column editor="text" name="ffbl" header="发放比例"></ep-table-column>
                            <ep-table-column editor="text" name="aae013" header="备注"></ep-table-column>
                        </ep-table>
                    </el-tab-pane>
                </el-tabs>
            </el-card>
        </el-main>
    </el-main>
</template>
<script type="es6">
    export default {
        data() {
            return {
                form:{
                    jjtcqd: {
                        value: '',
                        p: 'R'
                    },
                    aac147: {
                        value: '',
                        p: 'R'
                    },
                    aac058: {
                        key: '',
                        value: '',
                        p: 'R'
                    },
                    aac003: {
                        value: '',
                        p: 'R'
                    },
                    aac004: {
                        key: '',
                        value: '',
                        p: 'R'
                    },
                    aac005: {
                        value: '',
                        p: 'R'
                    },
                    aac006: {
                        value: '',
                        p: 'R'
                    },
                    aac009: {
                        key: '',
                        value: '',
                        p: 'R'
                    },
                    aac010: {
                        value: '',
                        p: 'R'
                    },
                    aac084: {
                        key: '',
                        value: '',
                        p: 'R'
                    },
                    eae443: {
                        value: '',
                        p: 'R'
                    },
                    bic121: {
                        key: '',
                        value: '',
                        p: 'R'
                    },
                    aae007: {
                        value: '',
                        p: 'R'
                    },
                    aae004: {
                        value: '',
                        p: 'R'
                    },
                    aae005: {
                        value: '',
                        p: 'R'
                    },
                    bae011: {
                        key: '',
                        value: '',
                        p: 'R'
                    },
                    bae012: {
                        key: '',
                        value: '',
                        p: 'R'
                    },
                    bae013: {
                        key: '',
                        value: '',
                        p: 'R'
                    },
                    aae006: {
                        value: '',
                        p: 'R'
                    },
                    eae003: {
                        key: '',
                        value: '',
                        p: 'R'
                    },
                    aae041: {
                        value: '',
                        p: 'R'
                    },
                    aae042: {
                        value: '',
                        p: 'R'
                    },
                    aae019: {
                        value: '',
                        p: 'R'
                    },
                    ffbl: {
                        value: '',
                        p: 'R'
                    },
                    aae013: {
                        value: '',
                        p: 'E'
                    },

                },
                activeName2: '1',
                tableData1: {},
                tableData2: {},
                panel: {},

                rules:{
                    jjtcqd: [
                        {required: true ,validator: this.$rules.test_noBlank, trigger: 'blur'}

                    ],
                    aac147: [
                        {required: true ,validator: this.$rules.test_noBlank, trigger: 'blur'}

                    ],
                    aac058: [
                        {required: true ,validator: this.$rules.test_noBlank, trigger: 'blur'}

                    ],
                    aac003: [
                        {required: true ,validator: this.$rules.test_noBlank, trigger: 'blur'}

                    ],
                    aac004: [
                        {required: true ,validator: this.$rules.test_noBlank, trigger: 'blur'}

                    ],
                    aac005: [
                        {required: true ,validator: this.$rules.test_noBlank, trigger: 'blur'}

                    ],
                    aac006: [
                        {required: true ,validator: this.$rules.test_noBlank, trigger: 'blur'}

                    ],
                    aac009: [
                        {required: true ,validator: this.$rules.test_noBlank, trigger: 'blur'}

                    ],
                    aac010: [
                        {required: true ,validator: this.$rules.test_noBlank, trigger: 'blur'}

                    ],
                    aac084: [
                        {required: true ,validator: this.$rules.test_noBlank, trigger: 'blur'}

                    ],
                    eae443: [
                        {required: true ,validator: this.$rules.test_noBlank, trigger: 'blur'}

                    ],
                    bic121: [
                        {required: true ,validator: this.$rules.test_noBlank, trigger: 'blur'}

                    ],
                    aae007: [
                        {required: true ,validator: this.$rules.test_noBlank, trigger: 'blur'}

                    ],
                    aae004: [
                        {required: true ,validator: this.$rules.test_noBlank, trigger: 'blur'}

                    ],
                    aae005: [
                        {required: true ,validator: this.$rules.test_noBlank, trigger: 'blur'}

                    ],
                    bae011: [
                        {required: true, message: '必填项，不能为空'}

                    ],
                    bae012: [
                        {required: true, message: '必填项，不能为空'}

                    ],
                    bae013: [
                        {required: true, message: '必填项，不能为空'}

                    ],
                    aae006: [
                        {required: true, message: '必填项，不能为空'}

                    ],
                    eae003: [
                        {required: true ,validator: this.$rules.test_noBlank, trigger: 'blur'}

                    ],
                    aae041: [
                        {required: true ,validator: this.$rules.test_noBlank, trigger: 'blur'}

                    ],
                    aae042: [
                        {required: true ,validator: this.$rules.test_noBlank, trigger: 'blur'}

                    ],
                    aae019: [
                        {required: true ,validator: this.$rules.test_noBlank, trigger: 'blur'}

                    ],
                    ffbl: [
                        {required: true ,validator: this.$rules.test_noBlank, trigger: 'blur'}

                    ],

                },
                codeTypes:{
                    AAC058:[],
                    AAC004:[],
                    AAC009:[],
                    AAC084:[],
                    BIC121:[],
                    EAE003:[],

                },
                codeTypeFilters:{

                },
                pager: {
                    page: 1,
                    size: 10
                },
                total: 0,
            }
        },
        computed: {
            functionId() {
                if (this.$store.getters.init.path !== this.$route.path) return;
                if (this.$store.getters.init.mdParam === null || this.$store.getters.init.mdParam === undefined) return;
                if (this.$store.getters.init.mdParam.functionid === undefined) return;
                return this.$store.getters.init.mdParam.functionid;
            },
            backFun() {
                return this.$store.getters.backFun;
            },
            init_formData() {
                if (this.$store.getters.init.path !== this.$route.path)  return;
                return this.$store.getters.init.form;
            },
            doInitformData: {
                get: function () {
                    if (this.$store.getters.common === null) return [];
                    if (this.$store.getters.common.path !== this.$route.path) return;
                    return this.$store.getters.common.formData;
                },
                set: function (newValue) {
                    if (newValue.path !== this.$route.path) return;
                    return newValue;
                }
            },
            init_panel() {
                if (this.$store.getters.init.path !== this.$route.path)  return;
                return this.$store.getters.init.panel;
            },
            doInitpanel: {
                get: function () {
                    if (this.$store.getters.common === null) return [];
                    if (this.$store.getters.common.path !== this.$route.path) return;
                    return this.$store.getters.common.panel;
                },
                set: function (newValue) {
                    if (newValue.path !== this.$route.path) return;
                    return newValue;
                }
            },

        },
        created() {
            let param = {
                path: this.$route.path,
                codeTypes:this.codeTypes,
                codeTypeFilters: window.btoa(JSON.stringify(this.codeTypeFilters)),
                form:this.form,
                tableData1:this.tableData1,
                tableData2:this.tableData2,
                panel:this.panel

            };
            this.$store.dispatch('SET_INIT', param);
        },
        watch: {
            init_formData: {
                handler(value) {
                    if (value == undefined) return;
                    this.getformData(value);
                },
                deep: true
            },
            doInitformData: {
                handler(value) {
                    if (value == undefined) return;
                    this.getformData(value);
                },
                deep: true
            },
            init_panel: {
                handler(value) {
                    if (value == undefined) return;
                    this.getpanel(value);
                },
                deep: true
            },
            doInitpanel: {
                handler(value) {
                    if (value == undefined) return;
                    this.getpanel(value);
                },
                deep: true
            },

            backFun: {
                handler(value) {
                    if (value === null) return;
                    this.customBackFun();
                    let backFun = [];
                    backFun = value.split(',');
                    if (backFun.indexOf('rDoInit') >= 0) {
                        let codeTypes = {
                            AAC058:[],
                            AAC004:[],
                            AAC009:[],
                            AAC084:[],
                            BIC121:[],
                            EAE003:[],

                        };
                        let form = {
                            jjtcqd: {
                                value: '',
                                p: 'R'
                            },
                            aac147: {
                                value: '',
                                p: 'R'
                            },
                            aac058: {
                                key: '',
                                value: '',
                                p: 'R'
                            },
                            aac003: {
                                value: '',
                                p: 'R'
                            },
                            aac004: {
                                key: '',
                                value: '',
                                p: 'R'
                            },
                            aac005: {
                                value: '',
                                p: 'R'
                            },
                            aac006: {
                                value: '',
                                p: 'R'
                            },
                            aac009: {
                                key: '',
                                value: '',
                                p: 'R'
                            },
                            aac010: {
                                value: '',
                                p: 'R'
                            },
                            aac084: {
                                key: '',
                                value: '',
                                p: 'R'
                            },
                            eae443: {
                                value: '',
                                p: 'R'
                            },
                            bic121: {
                                key: '',
                                value: '',
                                p: 'R'
                            },
                            aae007: {
                                value: '',
                                p: 'R'
                            },
                            aae004: {
                                value: '',
                                p: 'R'
                            },
                            aae005: {
                                value: '',
                                p: 'R'
                            },
                            bae011: {
                                key: '',
                                value: '',
                                p: 'R'
                            },
                            bae012: {
                                key: '',
                                value: '',
                                p: 'R'
                            },
                            bae013: {
                                key: '',
                                value: '',
                                p: 'R'
                            },
                            aae006: {
                                value: '',
                                p: 'R'
                            },
                            eae003: {
                                key: '',
                                value: '',
                                p: 'R'
                            },
                            aae041: {
                                value: '',
                                p: 'R'
                            },
                            aae042: {
                                value: '',
                                p: 'R'
                            },
                            aae019: {
                                value: '',
                                p: 'R'
                            },
                            ffbl: {
                                value: '',
                                p: 'R'
                            },
                            aae013: {
                                value: '',
                                p: 'E'
                            },

                        };
                        let tableData1= {};
                        let tableData2= {};
                        let panel= {};

                        let param = {
                            path: this.$route.path,
                            codeTypes:codeTypes,
                            codeTypeFilters: window.btoa(JSON.stringify(this.codeTypeFilters)),
                            form:form,
                            tableData1:tableData1,
                            tableData2:tableData2,
                            panel:panel

                        };
                        this.$store.dispatch('SET_INIT', param);
                    }
                }
            }
        },
        methods: {
            getformData(value) {
                this.form = value;
            },
            getpanel(value) {
                this.panel = value;
            },

            handleSizeChange(val) {
                console.log(`每页 ${val} 条`);
            },
            handleCurrentChange(val) {
                console.log(`当前页: ${val}`);
            },
            handleEdit(id) {
                this.dialogFormVisible = true;
            },
            formValidate(value){
                if(value && value.length>0){
                    value.map((item,index)=>{
                        this.$refs[value].validate((valid) => {
                            if (valid) {
                                if(index+1 == value.length){
                                    this.$refs.save.btn();
                                }
                            } else {
                                return false;
                            }
                        });
                    })
                }
            },

            customBackFun(){//自定义方法体
            },
        },
    }
</script>
